package cn.lyf.conf;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanPostProcessor;
import org.springframework.stereotype.Component;

// 后置处理器，在初始化前后处理
// spring 里有大量 xxAware 接口，用来注入
//@AutoWired注解,生命周期注解,@Async底层都是用BeanPostProcessor实现的
@Component
public class MyBeanPostProcessor implements BeanPostProcessor {

    @Override
    public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
        System.out.println("初始化前");
        return bean;
    }

    @Override
    public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
        System.out.println("初始化后");
        return bean;
    }

}

// classpath下对应包下面的所有*.class文件，resolveBasePackage(basePackage) 方法将包名称转换为路径名称，拼接为文件绝对路径
//String packageSearchPath = ResourcePatternResolver.CLASSPATH_ALL_URL_PREFIX +
//resolveBasePackage(basePackage) + '/' + this.resourcePattern;
// 文件解析为资源对象
//Resource[] resources = getResourcePatternResolver().getResources(packageSearchPath);
